﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

using Microsoft.AspNetCore.Http;

namespace tcm.Filters
{
    public static class HttpContextExtension
    {
        /// <summary>
        /// 获取请求令牌
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public static string GetToken(this HttpContext context)
        {
            return context.Request.Headers["Authorization"];
        }

        //public static long GetUId(this HttpContext context)
        //{
        //    var uid = context.User.FindFirst(ClaimTypes.PrimarySid).Value;

        //    return !string.IsNullOrEmpty(uid) ? long.Parse(uid) : 0;
        //}
        //public static string GetName(this HttpContext context)
        //{
        //    var uid = context.User?.Identity?.Name;

        //    return uid;
        //}
    }
}
